﻿#region 命名空间

using System;
using Sharp.Domain.Repositories;
using Sharp.Infrastructure;
using Sharp.Domain.Repository.EF;

#endregion

namespace Sharp.Domain.PlatformBoundedContext.OrgModule.Aggregates
{
    public partial class OrgRepository : Repository<Org>, IOrgRepository
    {

        public Result MoveOrSort(Guid? parentId, Guid[] ids)
        {
            Result res = new Result();

            for (int i = 0; i < ids.Length; i++)
            {
                var id = ids[i];
                var info = this.Get(x => id == x.Id);
                info.ParentId = parentId;
                info.OrderIndex = i;
            }

            this.Context.Commit();
            res.Message = "保存成功！";

            return res;
        }
    }
}